package leetcode.Y2024M5D27;

import java.util.Deque;
import java.util.LinkedList;

/**
 * S155
 */
public class MinStack {
    private Deque<int[]> stack=new LinkedList<>();
    public MinStack() {
    }

    public void push(int val) {
        if (stack.isEmpty()){
            stack.push(new int[]{val,val});
        }else {
            stack.push(new int[]{val,Math.min(val,stack.peek()[1])});
        }
    }

    public void pop() {
        stack.pop();

    }

    public int top() {
        return stack.peek()[0];
    }

    public int getMin() {
        return stack.peek()[1];
    }
}
